//
//  CalendarDiaryItemView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/2/18.
//

import SwiftUI

//月试图- 心情
struct CalendarMoodMonthItemView: View {
    let item: StatisticsDiaryBean
    let width: Double
    var body: some View {
         VStack(spacing: 0) {
            let _ = Self._printChanges()  // 打印视图刷新的原因
            if item.isYear {
                Text(String(item.year))
                    .font(.custom(IFontType.number.rawValue, size: 24))
                    .fontWeight(.bold)
                    .fontWeight(.bold)
                    .foregroundStyle(.bgNormalText)
            }
            Text("\(item.month)月")
                .padding(.top,10)
                .font(.system(size: 18))
                .foregroundStyle(themeManager.themeColor)
            Text("\(item.events?.count ?? 0)天记录")
                .padding(.top,5)
                .font(.system(size: 14))
                .foregroundStyle(.bgNormalText3)
            // 日历视图
            CalendarView(yearOrmonth: String(item.yearOrmonth), events: item.events,viewWidth: width) { calendarBean in
                let event = calendarBean.event
                let diary = event as? DiaryBean ?? nil
                return CalendarMoodItemView(day: calendarBean.day, isToday: calendarBean.isToday, bean: diary, itemsWidth: width / 7)
            }.padding(.top, 10)
        }
    }
}

#Preview {
    CalendarMoodMonthItemView(item: StatisticsDiaryBean(), width: 100)
}
